package com.hitemole.levelObject;

import com.hitemole.interfaces.IScore;

public class Scores implements IScore{
	private final static int MIN_SCORE_INCREMENT=1;
	private final static int MAX_SCORE_INCREMENT=6;
	
	protected int playerScore;
	protected String playerName;
	protected int gameMode;
	
	protected int multiplier;
	
	private int scoreThresholder;
	
	public Scores(String playerName,int gameMode){
		this.playerName=playerName;
		this.playerScore=0;
		this.scoreThresholder=0;
		this.gameMode=gameMode;
		this.multiplier=1;
	}
	
	@Override
	public void addScore(int scoreToAdd) {
		// TODO Auto-generated method stub
		scoreThresholder+=(scoreToAdd*multiplier);
	}
	
	public void setTargetScore(int scoreToAdd){
		scoreThresholder=scoreToAdd;
	}
	
	public void setMultiplier(int multiplier){
		this.multiplier=multiplier;
	}
	
	public String getMultiplier(){
		return Integer.toString(multiplier);
	}

	@Override
	public void setScore(int score) {
		// TODO Auto-generated method stub
		this.playerScore=score;
	}

	@Override
	public int getScore() {
		// TODO Auto-generated method stub
		return playerScore;
	}
	
	public String getStringScore() {
		// TODO Auto-generated method stub
		String playerToString=Integer.toString(playerScore);
		String tempScore = "";
		for(int i=0; i<8-playerToString.length();i++){
			tempScore=tempScore+"0";
		}
		playerToString=tempScore+playerToString;
		return playerToString;
	}

	@Override
	public void setPlayerName(String player) {
		// TODO Auto-generated method stub
		this.playerName=player;
	}

	@Override
	public String getPlayerName() {
		// TODO Auto-generated method stub
		return playerName;
	}

	@Override
	public void saveScore() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public int getGameMode() {
		// TODO Auto-generated method stub
		return gameMode;
	}

	@Override
	public void setGameMode(int gameMode) {
		// TODO Auto-generated method stub
		this.gameMode=gameMode;
	}
	
	public void update(float delta){
		if(scoreThresholder==playerScore){
			return;
		}
		if((scoreThresholder-playerScore)>=30){
			playerScore+=MAX_SCORE_INCREMENT;
		}else if((scoreThresholder-playerScore)<30){
			playerScore+=MIN_SCORE_INCREMENT;
		}
	}
	
	public void resetScore(){
		this.playerScore=0;
		this.scoreThresholder=0;
		this.multiplier=1;
	}

}
